package com.mdlib.helper.ui.adapter;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljlib.core.util.common.TimeUtils;
import com.ljlib.help.R;
import com.mdlib.helper.model.entity.MoneyRelateEneity;
import com.mdlib.helper.ui.UIHelper;

import java.util.List;

/**
 * 作者：HQY on 16/11/16 16:52
 * 邮箱：hqy_xz@126.com
 */

public class MoneyRelateAdapter extends BaseQuickAdapter<MoneyRelateEneity> {
    private String relateType = UIHelper.BUDGET;

    public MoneyRelateAdapter(List<MoneyRelateEneity> data, String relate) {
        super(R.layout.item_money_relate, data);
        this.relateType = relate;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, MoneyRelateEneity moneyRelate) {


        TextView mTvTitle = baseViewHolder.getView(R.id.tv_relate_title);


        if (relateType.equals(UIHelper.BUDGET)) {

            baseViewHolder.setText(R.id.tv_money_time_day, TimeUtils.milliseconds2String(Long.valueOf(moneyRelate.getCreatedAt()) * 1000, TimeUtils.YEARS));
            baseViewHolder.setText(R.id.tv_money_time_hour, TimeUtils.milliseconds2String(Long.valueOf(moneyRelate.getCreatedAt()) * 1000, TimeUtils.HOURS));
            if (moneyRelate.getType() == 1) {
                mTvTitle.setText("充值成功");
                baseViewHolder.setText(R.id.tv_relate_money, "+" + moneyRelate.getMoney());
            } else if (moneyRelate.getType() == 2) {
                if (moneyRelate.getStatus() == 1) {
                    mTvTitle.setText("提现审核中");
                } else if (moneyRelate.getStatus() == 2) {
                    mTvTitle.setText("提现申请通过");
                } else if (moneyRelate.getStatus() == 3) {
                    mTvTitle.setText("提现申请失败");
                } else if (moneyRelate.getStatus() == 4) {
                    mTvTitle.setText("提现完成");
                }
                baseViewHolder.setText(R.id.tv_relate_money, "-" + moneyRelate.getMoney());
            } else if (moneyRelate.getType() == 3) {
                mTvTitle.setText("退款成功");
                baseViewHolder.setText(R.id.tv_relate_money, "+" + moneyRelate.getMoney());
            } else if (moneyRelate.getType() == 4) {
                mTvTitle.setText("订单收益");
                baseViewHolder.setText(R.id.tv_relate_money, "+" + moneyRelate.getMoney());
            } else if (moneyRelate.getType() == 5) {
                mTvTitle.setText("付款给订单成功");
                baseViewHolder.setText(R.id.tv_relate_money, "-" + moneyRelate.getMoney());
            }

        } else if (relateType.equals(UIHelper.WITHDRAWAL)) {
            baseViewHolder.setText(R.id.tv_relate_money, "-" + moneyRelate.getMoney());
            baseViewHolder.setText(R.id.tv_money_time_day, TimeUtils.milliseconds2String(Long.valueOf(moneyRelate.getCreatedTime()) * 1000, TimeUtils.YEARS));
            baseViewHolder.setText(R.id.tv_money_time_hour, TimeUtils.milliseconds2String(Long.valueOf(moneyRelate.getCreatedTime()) * 1000, TimeUtils.HOURS));
            if (moneyRelate.getStatus() == 1) {
                mTvTitle.setText("提现审核中");
            } else if (moneyRelate.getStatus() == 2) {
                mTvTitle.setText("提现申请通过");
            } else if (moneyRelate.getStatus() == 3) {
                mTvTitle.setText("提现申请失败");
            } else if (moneyRelate.getStatus() == 4) {
                mTvTitle.setText("提现完成");
            }
        }


    }
}
